<?php
require __DIR__.'/../vendor/autoload.php';

use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

class Connect
{
    private static  $vhost = 'MemberHost';

    private static $obj = null;

    public static function conn()
    {
        $host = '192.168.3.203';
        $port = '5672';
        $user = 'MemberAdmin';
        $pwd = '123456';
        return new AMQPStreamConnection($host, $port, $user, $pwd, self::$vhost);
    }

    public static function getInstance($vhost = 'MemberHost')
    {
        if (!self::$obj) {
            if ($vhost) self::$vhost = $vhost;
            self::$obj = self::conn();
        }
        return self::$obj;
    }
}
